package com.atguigu07._abstract.ex2;

import java.util.Scanner;

public class EployeeTest {
    public static void main(String[] args) {
        MyDate date1=new MyDate(1997,5,3);
        MyDate date2=new MyDate(1998,7,1);
        MyDate date3=new MyDate(1999,10,4);
        MyDate date4=new MyDate(2000,9,15);
        Employee[] employees=new Employee[4];
        employees[0]=new SalariedEmployee("tom",1001,date1,8000);
        employees[1]=new SalariedEmployee("tim",1002,date2,9000);
        employees[2]=new SalariedEmployee("li",1003,date3,10000);
        employees[3]=new HourlyEmployee("liu",1003,date4,120,8);
        Scanner scanner=new Scanner(System.in);
        System.out.println("输入本月月份");
        String month=scanner.next();
        int mon=Integer.parseInt(month);
        for (int i = 0; i <employees.length ; i++) {
            if(employees[i] instanceof SalariedEmployee){
                SalariedEmployee e=(SalariedEmployee)employees[i];
                e.setMonthlySalary(e.earning(mon));
                if(e.getDate().getMonth()==mon){
                    System.out.println("加工资");
                }
                System.out.println(employees[i].toString());
            }
            else{
                HourlyEmployee ee=(HourlyEmployee)employees[i];
                System.out.println(employees[i].toString());
            }
//            System.out.println(employees[i].getClass()+" "
//            +employees[i].getName()+" "
//             +employees[i].getNumber()+" "
//            +employees[i].getDate().printBirth()
//            );


        }
    }
}
